#{extends 'main.html' /}
#{set title:messages.get("deal.admin.new.deal.text") /}

#{set 'moreScripts'}
    <script src="@{'/public/javascripts/jquery-ui-1.7.2.custom.min.js'}" type="text/javascript" charset="${_response_encoding}"></script>
#{/set}
#{set 'moreStyles'}
    <link rel="stylesheet" type="text/css" media="screen" href="@{'/public/ui-lightness/jquery-ui-1.7.2.custom.css'}" />
#{/set}
        	
<h1>&{'deal.admin.new.deal.text'}</h1>
<div class="register newDeal">
#{form @saveDeal(), enctype:'multipart/form-data'}
    
    #{field 'deal.title'}
        <p class="${field.errorClass}">
            <label>&{'deal.title'}:</label> <input type="text" name="${field.name}" size="16" value="${deal?.title}"> *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
    #{field 'deal.description'}
        <p class="${field.errorClass}">
            <label>&{'deal.admin.deal.description'}:</label> <textarea style="font-family:arial,sans-serif" rows="7" cols="40" name="${field.name}">${deal?.description}</textarea> *
            <span class="error">${field.error}</span>
        </p>
        
    #{/field}
    
    #{field 'deal.oldPrice'}
        <p class="${field.errorClass}">
            <label>&{'view.deal.original.price'}:</label> <input type="text" name="${field.name}" size="16" value="${deal?.oldPrice}"> *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
    #{field 'deal.discountPrice'}
        <p class="${field.errorClass}">
            <label>&{'view.deal.discount.price'}:</label> <input type="text" name="${field.name}" size="16" value="${deal?.discountPrice}"> *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
     #{field 'deal.startDate'}
        <p class="${field.errorClass}">
            <label>&{'deal.admin.deal.startDate'}:</label> <input type="text" size="10" name="${field.name}" class="datepicker" value="${deal?.startDate?.format()}"> *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
    #{field 'deal.endDate'}
        <p class="${field.errorClass}">
            <label>&{'deal.admin.deal.endDate'}:</label> <input type="text" size="10" name="${field.name}" class="datepicker" value="${deal?.endDate?.format()}"> *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
	
	#{field 'deal.photo'}
        <p class="${field.errorClass}">
            <label>Photo:</label> <input type="file" size="39" name="${field.name}" value="${deal?.photo}">
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
    
    #{field 'deal.category.id'}
        <p class="${field.errorClass}">
            <label>&{'search.category'}:</label>
            <select name="${field.name}"> 
				#{list items:categories, as:'category'} 
				    <option value="${category.id}">${category.categoryName}</option> 
				#{/list} 
			</select>  *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
     #{field 'deal.district.id'}
        <p class="${field.errorClass}">
            <label>&{'address.district'}:</label>
            <select name="${field.name}"> 
				#{list items:districts, as:'district'} 
				    <option value="${district.id}">${district.districtName}</option> 
				#{/list} 
			</select>  *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
    #{field 'deal.address.city'}
        <p class="${field.errorClass}">
            <label>&{'address.city'}:</label> <input type="text" name="${field.name}" size="16" value="${deal?.address?.city}"> *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
    #{field 'deal.address.zipCode'}
        <p class="${field.errorClass}">
            <label>&{'address.zipcode'}:</label> <input type="text" name="${field.name}" size="16" value="${deal?.address?.zipCode}"> *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
    #{field 'deal.address.street'}
        <p class="${field.errorClass}">
            <label>&{'address.street'}:</label> <input type="text" name="${field.name}" size="16" value="${deal?.address?.street}"> *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    
    #{field 'deal.address.houseNumber'}
        <p class="${field.errorClass}">
            <label>&{'address.house.number'}:</label> <input type="text" name="${field.name}" size="16" value="${deal?.address?.houseNumber}"> *
            <span class="error">${field.error}</span>
        </p>
    #{/field}
    <button type="submit">&{'save.deal.button'}</button>
#{/form}
</div>
<script type="text/javascript" charset="${_response_encoding}">
    $(function() {
		$(".datepicker").datepicker({dateFormat: '&{'jquery.dateFormat'}'});
	});
</script>